# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=py3-pyclipper
_pyname=pyclipper
pkgver=1.3.0_p5
pkgrel=1
pkgdesc="Cython wrapper for clipper"
url="https://github.com/fonttools/pyclipper"
arch="all"
license="MIT"
depends="python3"
makedepends="
	clipper-dev
	cython
	py3-gpep517
	py3-setuptools
	py3-setuptools_scm
	py3-wheel
	python3-dev
	"
checkdepends="py3-pytest py3-pytest-runner"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/p/$_pyname/$_pyname-${pkgver/_p/.post}.tar.gz
	10-system-libs.patch
	disable-broken-test.patch
	"
builddir="$srcdir/$_pyname-${pkgver/_p/.post}"

prepare() {
	default_prepare
	# For system-wide consistency, and to save installation space,
	# we use the shared library from Alpine package "clipper".
	rm src/clipper.cpp src/clipper.hpp

	# force cython regen
	touch dev
	rm src/pyclipper/_pyclipper.cpp
}

build() {
	CYTHON_FORCE_REGEN=1 \
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
a47371f57684e14a68fee4565d9541f1b8e9e6b13b005f62719399702b497c94602cd3287b77ada9f3a1a580245d8386d6d8851628dce25143ba4077298981a8  pyclipper-1.3.0.post5.tar.gz
b45fdd6449a07e17d22c936353de42da6bc00a48c25abe886249fedbde700f7032bc8c05c2c6ef26748f074931907cf453ae1c8bbce82f90d945991fff9e0c05  10-system-libs.patch
06ced9f3410f436986109a7f0d54ccdd69597e75fb44c26d9dd1909b59a1a987f07ad55d2a0e24d114f2af31b3aa51cd6f44d7fe1658a625ac53e33bef379d8a  disable-broken-test.patch
"
